package juc.test;

import lombok.extern.slf4j.Slf4j;

@Slf4j(topic = "c.BasicUse")
public class BasicUse {
    public static void main(String[] args) {
        Thread thread = new Thread(){
            @Override
            public void run() {
                log.debug("running");
            }
        };
        thread.setName("baka1");
        thread.start();
        log.debug("running");

        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                log.debug("running");
            }
        };
        Thread thread1 = new Thread(runnable);
        thread1.start();

        // lambda
        Runnable task = () -> {
            log.debug("running");
        };
        Thread thread2 = new Thread(task);
        thread2.start();
        //推荐使用Runnable 将线程和任务分开来 而且由于是接口方式，避免了继承
    }
}
